package com.pig4cloud.pig.village.section.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.village.api.dto.SectionSelect;
import com.pig4cloud.pig.village.api.entity.Section;
import com.pig4cloud.pig.village.section.service.ISectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Allen.Xie
 * @date 2022/3/15
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/section")
@Api(value = "section", tags = "分管片区")
public class SectionController {
	@Resource
	private ISectionService sectionService;

	@ApiOperation(value = "分页")
	@GetMapping("/page")
	public R<IPage<Section>> page(Integer pageNum, Integer pageSize) {
		return R.ok(sectionService.page(new Page(pageNum,pageSize)));
	}

	@ApiOperation(value = "全部分管片区下拉框-all")
	@GetMapping("/listSectionAllSelect")
	public R<List<SectionSelect>> listSectionAllSelect() {
		return R.ok(sectionService.listAllSelect());
	}

}
